<?php
/**
 * Author:Arthur
 * Date:2013-2-20
 * File Name:send_statistics_class.php
 * Email:kingarthurx@sina.cn
 */
class statistics{
 	private $message_content;
 	private $contact_list_id;
 	private $norepeat;
 	private $userapi_id;
 	private $api_id;
 	private $sms_record_time;
 	private $sms_success_list;
 	private $sms_fail_list;
 	private $sms_success_count;
 	private $sms_fail_count;
 	private $sms_content;
 	private $user_id;
 	private $department_id;
 	private $company_id;
 	private $sms_record_remark;
 	private $isentry;
 	private $mobile_list;
 	private $cost;
 	 	/*
 	 * 获取私有变量
 	 * */
 	 public function __get($allVariables){
 	 	if(isset($this->$allVariables)){
 	 		return $this->$allVariables;
 	 	}
 	 	else
 	 	{
 	 		return null;
 	 	}
 	 }
 	/*
 	 * 设置私有变量
 	 * */
 	 public function __set($allVariables,$value){
 	 	$this->$allVariables = $value;
 	 }
 	 /**
 	 * 查询短信发送记录
 	 * */
 	function queryMessageHistory(){
 		$sql="SELECT sms_record_id,api_id,zy_sms_record.sms_record_time,sms_content,zy_user.`user_real_name`,COUNT(sms_success_list) AS quantity   FROM `zy_sms_record` LEFT JOIN zy_user ON zy_sms_record.`user_id` = zy_user.`user_id`  WHERE zy_sms_record.company_id=$this->company_id GROUP BY DATE_FORMAT(zy_sms_record.sms_record_time, '%Y-%m-%d %H') DESC  limit ".($GLOBALS['pages']-1)*$GLOBALS['displaypg'].",".$GLOBALS['displaypg'];
 		$arr=$GLOBALS['mysql']->select($sql);
	    return $arr;
	}
	/**
 	 * 查询短信发送记录
 	 * */
 	function countMessageHistory(){
 		$sql = "SELECT COUNT(*) as count FROM (	
				SELECT COUNT(sms_success_list) AS quantity, sms_record_time FROM `zy_sms_record` 
				LEFT JOIN zy_user ON zy_sms_record.`user_id` = zy_user.`user_id`  
				WHERE zy_sms_record.company_id=$this->company_id GROUP BY DATE_FORMAT(zy_sms_record.sms_record_time, '%Y-%m-%d %H')) AS ss";
 		$count=$GLOBALS['mysql']->selectId($sql);
	 	return $count->count;
	}
	
 }